<div class="transactions form">
    <?php //$this->Html->script("tr_add.js", array("inline" => false)); ?>
    <?php //$this->Html->css("tran_css", array("inline" => false)); ?>

    <?php echo Form::open();?>
    <fieldset>
        <legend><?php echo __('Search Transaction'); ?></legend>
       <?php echo Form::select('type',$type,$option_type); ?>
        <h4 id="category12" style="cursor:pointer;"> Find with Category? </h4> <?php
        echo Form::select('category_id',@$category1,$option_category);
        echo " <br/><br/><br/>";
        echo Form::select('wallet_id',@$value_wallet,$option_wallet);
        echo "<br/> <br/>";
        echo Form::submit();
        ?>
<!--        <h4 id="time12" style="cursor:pointer;">Find with time? </h4>
        <div id="time123" style="display:none;">
            <?php
           // echo Form::select('time');
            ?>
        </div>-->
        
    </fieldset>
    <?php Form::close(); ?>
</div>


<div class="transactions index">
    <h2><?php echo __('Transactions'); ?></h2>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th><?php echo 'id'; ?></th>
            <th><?php echo 'category_id'; ?></th>
            <th><?php echo 'wallet_id'; ?></th>
            <th><?php echo 'parent_id'; ?></th>
            <th><?php echo 'money'; ?></th>
            <th><?php echo 'with_who'; ?></th>
            <th class="actions"><?php echo __('Actions'); ?></th>
        </tr>
        <?php foreach ($transactions as $transaction):  ?>
            <tr>
                <td><?php echo $transaction->id; ?>&nbsp;</td>
                <td>
                    <?php echo Html::anchor('categories/view/'.$transaction->categories->id, $transaction->categories->name); ?>
                </td>
                <td>
                     <?php echo Html::anchor('categories/view/'.$transaction->wallets->id, $transaction->wallets->name); ?>
                 <br/> <?php echo @$transaction->wallets->current_money; ?>
                </td>
                <td>
                    <?php if($transaction->parent_transaction != null )
                        {
                        Html::anchor('transactions/view/'.$transaction->parent_transaction->id, $transaction->parent_transaction->id); 
                        }
                        ?>
                
                </td>
                <td><?php echo $transaction->money; 
                if(@$transaction->child_transaction->money != null)
                {       $conlai= @$transaction->money- @$transaction->child_transaction->money; 
                        if($conlai!=0){
                    echo "<br/>"."Còn lại : ".$conlai;
                        }
                        else{echo "<br/>"."Đã trả hết";}
                }
                
                
                ?>&nbsp;</td>
                <td><?php echo $transaction->with_who; ?>&nbsp;</td>
                <td class="actions">
                    <?php echo Html::anchor('transactions/view/'.$transaction->id,'View');?>
                    <?php echo Html::anchor('transactions/edit/'.$transaction->id,'Edit');?>
                    <?php echo Html::anchor('transactions/delete/'.$transaction->id,'Delete',array("onClick " =>" javascript:return confirm('Bạn muốn delete ?') "));?>
                </td>
            </tr>
        <?php endforeach; ?>
    </table>
    <div class="paging">
        
        <?php
                echo Pagination::instance('mypagination')->pages_render();
                echo Pagination::instance('mypagination')->previous();
                echo Pagination::instance('mypagination')->next();
	?>
        
    </div>
</div>
<div class="actions">
    <h3><?php echo __('Actions'); ?></h3>
    <ul>
        <li><?php echo Html::anchor('transactions/add/','New transaction'); ?></li>

    </ul>
</div>
